package main

import (
	"fmt"
	"math/rand"
	"sync"
	"time"
)

func produce(ch chan<- int) {
	for {
		ch <- rand.Intn(10)
		time.Sleep(1 * time.Second)
	}
}

func consume(ch <-chan int) {
	for {
		t := <-ch
		fmt.Println("消费， 从只读通道接受", t)
	}
}

func main() {
	var wg sync.WaitGroup
	wg.Add(1)
	c := make(chan int)
	go produce(c)
	go consume(c)
	wg.Wait()
}
